package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/1/11 15:06
 * @description
 */
public class Code937 {
    public String[] reorderLogFiles(String[] logs) {
        String num = "0123456789";
        List<String> l1 = new ArrayList<>();
        List<String> l2 = new ArrayList<>();
        for (String log : logs) {
            if (num.contains(log.split(" ")[1].charAt(0) + "")) {
                l2.add(log);
            } else {
                l1.add(log);
            }
        }
        l1.sort((x, y) -> {
            x = x.substring(x.indexOf(" "));
            y = y.substring(y.indexOf(" "));
            return x.compareTo(y);
        });
        l1.addAll(l2);
        l1.toArray(logs);
        return logs;
    }
}
